{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="{:url('Material/index')}?nav=material-materiallist">材质</a>
  <a><cite>{if !empty($data_list['id']) }编辑{else/}添加{/if}材质</cite></a>
</span>
<div class="layui-fluid">
  <div class="layui-card">
   <form class="layui-form" action="" style='padding:10px'>
       
         <div class="layui-form-item">
           <label class="layui-form-label">名称</label>
           <div class="layui-input-block">
               <input type="text" name="material_name" value="{if !empty($data_list['material']) }{$data_list['material']}{/if}" autocomplete="off" placeholder="请输入材质名称" class="layui-input">
           </div>
         </div>

         <div class="layui-form-item">
           <label class="layui-form-label">描述</label>
           <div class="layui-input-block">
                <textarea id="content" name="content" style="width:100%;height:300px;">{if !empty($data_list['des']) }{$data_list['des']}{/if}</textarea>
           </div>
         </div>

         <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
              <button type="button" class="layui-btn layui-btn-sm" onclick="insert_edit({if !empty($data_list['id']) }{$data_list['id']}{else/}'tj'{/if})">确 定</button>
            </div>
          </div>
        
     </form>
 </div> 
</div>

{include file="/public/footer" /}

<script charset="utf-8" src="/static/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
<script>
  KindEditor.ready(function(K) {
    window.editor=K.create('#content',{'items':['source', '|', 'undo', 'redo', '|','selectall', 'preview', 'print', 'code', 'cut', 'copy', 'paste','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright','justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript', 'clearhtml', 'quickformat', '|','formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold','italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak','anchor', 'link', 'unlink','|', 'fullscreen'],'uploadJson':"{:url('Base/kindeditor_upload')}",afterCreate : function() { this.sync(); },afterBlur: function(){this.sync();}
    });

  })
  function insert_edit(id){
      layer.load();
      var material_name=$.trim($("input[name='material_name']").val());
      var des=$.trim($("textarea[name='content']").val());
      if(material_name==''){
          layer.closeAll('loading');
          layer.msg('请填写材质名称');
          return false;
      }

      if(id=='tj'){
        var url="{:url('Material/do_change')}";
      }else{
        var url="{:url('Material/do_change')}"+"?id="+id;
      }
      $.post(url,{material_name:material_name,des:des},function(res){
        if(res.status=='0'){
            layer.closeAll('loading');
            layer.msg(res.msg);
        }
        if(res.status=='1'){
            layer.msg(
            res.msg,{time: 1500 },
            function(){
              layer.closeAll();
              location.href=location.href;
            });
        }
    }) 
  }
</script>    

